import { Body, Controller, Delete, Get, Param, Post, Put } from "@nestjs/common";
import { wrapResult } from "src/common/r";
import { Activity } from "src/entity/activity";
import { ActivityService } from "src/service/activity";

@Controller('activity')
export class ActiovityController {
  constructor(private readonly service: ActivityService) { }

  @Get()
  async getAll() {
    return wrapResult(200, 'success', await this.service.findAll())
  }

  @Get(':id')
  async getById(@Param("id") id: number) {
    return wrapResult(200, 'success', await this.service.findOne(id))
  }

  @Post()
  async addAddress(@Body() entity: Activity) {
    return wrapResult(200, 'suucess', await this.service.addOne(entity))
  }

  @Put()
  async updateOne(@Body() entity: Activity) {
    return wrapResult(200, 'success', await this.service.updateOne(entity))
  }

  @Delete(':id')
  async removeOne(@Param('id') id: number) {
    return wrapResult(200, 'success', await this.service.remove(id))
  }
}


